package  
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	
	/**
	 * ...
	 * @author xekko_child
	 */
	public class MainMenu extends Sprite 
	{
		static private const BUTTON_HEIGHT:				Number 		= 50;
		static private const PLAYBUTTON_POSITION:		Number 		= 0;
		static private const CREDITSBUTTON_POSITION:	Number 		= 1;
		
		public var playbutton:				Button 		= new Button(new playsymb());
		public var creditsbutton:			Button 		= new Button(new creditssymb());
		public var buttonssprite:			Sprite 		= new Sprite();
		public var _fon:					fon 		= new fon();
		public var credit:					credits		= new credits();
		
		public function MainMenu() 
		{
			addEventListener(Event.ADDED_TO_STAGE, init)
		}
		
		private function init(e:Event):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
			addChild(_fon);
			addChild(buttonssprite);
			buttonssprite.addChild(playbutton);
			buttonssprite.addChild(creditsbutton);
			playbutton.y = PLAYBUTTON_POSITION * BUTTON_HEIGHT;
			playbutton.addEventListener(MouseEvent.CLICK, startgame);
			creditsbutton.addEventListener(MouseEvent.CLICK, creditsopen);
			creditsbutton.y = CREDITSBUTTON_POSITION * BUTTON_HEIGHT;
			buttonssprite.x = Main.GAME_WIDTH / 2 - buttonssprite.width / 2;
			buttonssprite.y = Main.GAME_HEIGHT / 2 - buttonssprite.height / 2;
		}
		
		private function creditsopen(e:MouseEvent):void 
		{
			stage.addChild(credit);
			credit.addEventListener(MouseEvent.CLICK, creditsclose);
		}
		
		private function creditsclose(e:MouseEvent):void 
		{
			stage.removeChild(credit);
		}
		
		private function startgame(e:MouseEvent):void 
		{
			Main.m.removeChild(Main._mm);
			Main.m.addChild(Main._wr);
		}
	}

}